package com.chengcheng.tuan.activity;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.view.ViewGroup;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemClickListener;
import android.widget.BaseAdapter;
import android.widget.ListView;

import com.chengcheng.tuan.R;
import com.chengcheng.tuan.R.id;
import com.chengcheng.tuan.R.layout;

public class ListActivity extends Activity {

	private ListView listview ;
	private ViewGroup header;
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_list);
		listview = (ListView)findViewById(R.id.list);
		header = (ViewGroup)getLayoutInflater().inflate(R.layout.listheader_list, null);
		listview.addHeaderView(header);
		listview.setAdapter(new BaseAdapter() {
			
			public View getView(int arg0, View arg1, ViewGroup arg2) {
				if(arg1!=null){
					return arg1;
				}else{
					return getLayoutInflater().inflate(R.layout.listitem_hotel_poi, null);
				}
			}
			
			@Override
			public long getItemId(int arg0) {
				// TODO Auto-generated method stub
				return arg0;
			}
			
			@Override
			public Object getItem(int arg0) {
				// TODO Auto-generated method stub
				return arg0;
			}
			
			@Override
			public int getCount() {
				// TODO Auto-generated method stub
				return 20;
			}
		});
		listview.setOnItemClickListener(new OnItemClickListener() {

			@Override
			public void onItemClick(AdapterView<?> arg0, View arg1, int arg2,
					long arg3) {
				Intent intent = new Intent(ListActivity.this, DetailActivity.class);
				startActivity(intent);
			}
			
		});
	}
}
